#ifndef __GUI_GL_WIDGET_H__
#define __GUI_GL_WIDGET_H__

#include <QGLWidget>
#include "definitions.h"

class Camera;

enum TransformationType {
  TTTranslation,
  TTRotation,
  TTScale,
};

class GLWidget: public QGLWidget {
Q_OBJECT

signals:
  void drawObjects();
public:
  GLWidget(QWidget * _parent);
  ~GLWidget();
private slots:

protected:
  void initializeGL();
  void resizeGL(int _w, int _h);
  void paintGL();

private:
  enum Event {
    ZOOM,
    ROTATION,
    TRANSLATION,
    SELECTION,
    NONE
  } currentEvent;

  void drawBackground();
  void drawGrid();
  void drawAxis();

  void initSelection(int _x, int _y);
  void processSelection(int _hits);
  void selectionMove(const QPoint & _p);

  void mouseMoveEvent(QMouseEvent * _event);
  void mousePressEvent(QMouseEvent * _event);
  void mouseReleaseEvent(QMouseEvent * _event);
  void wheelEvent(QWheelEvent * _event);

  Camera * camera;

  unsigned int * selectionBuffer;
  QPoint selectionPoint;
};

#endif
